#!/usr/bin/env python
# encoding: utf-8


"""
@file: trig_question_converts.py
@time: 2017/2/22 上午11:34
"""
from mathsolver.functions.base import *
from sympy import expand_trig


# 三角函数问题的转换


def _convert1(q_f):
    f = sympify(q_f)
    symbs = list(f.free_symbols)
    if len(symbs) != 2:
        raise Exception('Type Match Error')
    angle_symb = symbs[0]
    f = expand_trig(f)
    return {angle_symb: lambda subs: f.subs(subs)}


_question_converts = [_convert1, ]


def question_convets(q):
    question_eq_converts = {}
    for q_c in _question_converts:
        try:
            eq_maps = q_c(q)
            for k, v in eq_maps.items():
                question_eq_converts[k] = v
        except Exception:
            pass
    return question_eq_converts
